{% extends "base.html" %}

{% block extra_css %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/api_doc.css') }}">
{% endblock %}

{% block content %}
<div class="api-doc-container">
    <h2>图像审核 API 文档</h2>
    
    <section class="api-section">
        <h3>接口概述</h3>
        <p>本API提供图片内容审核服务，支持本地图片上传和网络图片URL审核。</p>
    </section>

    <section class="api-section">
        <h3>认证方式</h3>
        <p>所有接口需要在请求头中携带认证信息：</p>
        <div class="code-block">
            <pre>Authorization: Bearer &lt;your_token&gt;</pre>
        </div>
    </section>

    <section class="api-section">
        <h3>1. 上传图片审核</h3>
        <div class="api-details">
            <p><strong>接口地址：</strong> /upload</p>
            <p><strong>请求方式：</strong> POST</p>
            <p><strong>Content-Type：</strong> multipart/form-data</p>
            <p><strong>请求参数：</strong></p>
            <table class="api-table">
                <tr>
                    <th>参数名</th>
                    <th>类型</th>
                    <th>必填</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>image</td>
                    <td>file</td>
                    <td>是</td>
                    <td>图片文件，支持PNG、JPG、JPEG、BMP、GIF格式</td>
                </tr>
            </table>
            <p><strong>请求示例：</strong></p>
            <div class="code-block">
                <pre>
curl -X POST \
  'http://your-domain/upload' \
  -H 'Authorization: Bearer your_token' \
  -F 'image=@/path/to/image.jpg'</pre>
            </div>
        </div>
    </section>

    <section class="api-section">
        <h3>2. 网络图片审核</h3>
        <div class="api-details">
            <p><strong>接口地址：</strong> /audit-url</p>
            <p><strong>请求方式：</strong> POST</p>
            <p><strong>Content-Type：</strong> application/json</p>
            <p><strong>请求参数：</strong></p>
            <table class="api-table">
                <tr>
                    <th>参数名</th>
                    <th>类型</th>
                    <th>必填</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>url</td>
                    <td>string</td>
                    <td>是</td>
                    <td>图片URL地址</td>
                </tr>
            </table>
            <p><strong>请求示例：</strong></p>
            <div class="code-block">
                <pre>
curl -X POST \
  'http://your-domain/audit-url' \
  -H 'Authorization: Bearer your_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com/image.jpg"
}'</pre>
            </div>
        </div>
    </section>

    <section class="api-section">
        <h3>3. 响应格式</h3>
        <div class="api-details">
            <p><strong>成功响应：</strong></p>
            <div class="code-block">
                <pre>
{
    "conclusion": "合规",
    "conclusionType": 1,
    "data": [
        {
            "type": 1,
            "msg": "存在涉黄内容",
            "probability": 0.89
        }
    ]
}</pre>
            </div>
            <p><strong>响应参数说明：</strong></p>
            <table class="api-table">
                <tr>
                    <th>参数名</th>
                    <th>类型</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>conclusion</td>
                    <td>string</td>
                    <td>审核结论：合规、不合规、疑似</td>
                </tr>
                <tr>
                    <td>conclusionType</td>
                    <td>integer</td>
                    <td>结论类型：1(合规)、2(不合规)、3(疑似)</td>
                </tr>
                <tr>
                    <td>data</td>
                    <td>array</td>
                    <td>详细审核结果</td>
                </tr>
            </table>
        </div>
    </section>

    <section class="api-section">
        <h3>4. 错误码说明</h3>
        <div class="api-details">
            <table class="api-table">
                <tr>
                    <th>错误码</th>
                    <th>说明</th>
                </tr>
                <tr>
                    <td>400</td>
                    <td>请求参数错误</td>
                </tr>
                <tr>
                    <td>401</td>
                    <td>未授权</td>
                </tr>
                <tr>
                    <td>404</td>
                    <td>资源不存在</td>
                </tr>
                <tr>
                    <td>500</td>
                    <td>服务器内部错误</td>
                </tr>
            </table>
        </div>
    </section>
</div>
{% endblock %} 